home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gigarom 1
/
Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso
/
FILES
/
QUI
/
UTI
/
Premier Plug-In Kit 1.0.cpt
/
Premier Plug-In Kit 1.0
/
MPW Examples
/
.a
/
BW.a
next >
Wrap
Text File
|
1992-03-04
|
2KB
|
84 lines
; Routine to Convert a GWorld to Black & White
;
; © 1991 Adobe Systems Inc.
; written by Randy Ubillos
;
; NOTE: this routine is called in 32-bit mode!
MACHINE MC68020
; void BW(Ptr srcpix, Ptr dstpix, short height, short rowBytes, Ptr lookup, Ptr repeat);
BWFrame RECORD {A6Link},DECR
repeat ds.l 1
lookup ds.l 1
rowBytes ds.l 1
height ds.l 1
dstpix ds.l 1
srcpix ds.l 1
Return ds.l 1
A6Link ds.l 1
LocalSize equ *
ENDR
;---- Local register usage
; a0 = src pix
; a1 = dst pix
; a2 = lookup table
; a3 = lookup table + 256
; a4 = lookup table + 512
; a5 = repeat table
;
; d0 = work
; d1 = work
; d2 = row counter
; d3 = rowBytes
; d4 = height
BW PROC export
WITH BWFrame
link a6,#LocalSize
movem.l a0-a5/d0-d4,-(sp) ; save the registers
move.l srcpix(a6),a0 ; a0 = srcpix
move.l dstpix(a6),a1 ; a1 = dstpix
move.l rowBytes(a6),d3
lsr.l #2,d3 ; d3 = rowLongs
move.l height(a6),d4 ; d4 = height
move.l lookup(a6),a2 ; a2 = red lookup
move.l a2,a3
add.w #256,a3 ; a3 = green lookup
move.l a2,a4
add.w #512,a4 ; a4 = blue lookup
move.l repeat(a6),a5 ; a5 = repeat lookup
moveq #0,d0 ; zero some temps
moveq #0,d1
bra.s lineend
linestart move.l d3,d2 ; start the row counter
bra.s rowend
rowstart addq #1,a0 ; skip alpha channel
move.b (a0)+,d0 ; get red byte
move.b 0(a2,d0.w),d1 ; lookup fraction
move.b (a0)+,d0 ; get blue byte
add.b 0(a3,d0.w),d1 ; add in fraction
move.b (a0)+,d0 ; get green byte
add.b 0(a4,d0.w),d1 ; now we have gray value
move.l (a5,d1*4),(a1)+ ; save 4 of them
rowend dbra d2,rowstart ; do all pixels
lineend dbra d4,linestart ; do all lines
movem.l (sp)+,a0-a5/d0-d4 ; all done
unlk a6
rts
ENDWITH
ENDP
END